package com.zxx.bookadapter;

import com.zxx.data.Book;
import com.zxx.data.Chapter;
import com.zxx.tyfx.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BookAdapter extends BaseAdapter {

	private Book mBook;

	private Context mContext;
	
	public BookAdapter(Context mContext,Book mBook){
		this.mBook = mBook;
		this.mContext	=	mContext;
		
	}
	
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mBook.chapterList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return (Chapter)mBook.chapterList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View view, ViewGroup viewgroup) {
		// TODO Auto-generated method stub
		view	=	LayoutInflater.from(mContext).inflate(R.layout.book_item,null);
		TextView textView	=	(TextView)view.findViewById(R.id.text1);
		textView.setText(((Chapter) mBook.chapterList.get(arg0)).getName());
		return view;
	}

}
